package cn.wolfcode.web.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@Component
public class CheckLoginInterceptor implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //从session中获取用户信息
        Object employee = request.getSession().getAttribute("USER_IN_SESSION");
        if(employee!=null){
            return true;
        }
        response.sendRedirect("/login.html");
        return false;
    }
}
